<template>
	<view class="mainpadding beijingse">
		<view class="flexleft">
			<view class="line"></view>
			<view class="titletext bold hei_text margin_left1">基本信息</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top">
			<view class="ershib">姓名</view>
			<input class="inputs " type="text" style="text-align: right;" placeholder="请输入真实姓名" v-model="real_name">
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top">
			<view class="ershib">身份证号</view>
			<input class="inputs " type="text" style="text-align: right;" placeholder="请输入身份证号" v-model="id_card">
		</view>
		<!-- 固定底部 -->
		<view class="posibottom mainpadding" @click.stop="smrz">
			<view class="submitbtn">确定</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				real_name: "",
				id_card: "",
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(){
				httpRequest.request('/api/user/index','GET',{
				}).then(res => {
					this.real_name = res.data.name
					this.id_card = res.data.idcard
				})
			},
			// 实名认证
			smrz() {
				uni.showLoading({
					title: '请稍候...',
					mask: true
				})
				if (this.real_name == "") {
					uni.hideLoading()
					httpRequest.toast("请输入真实姓名")
					return
				}
				if (this.id_card == "") {
					uni.hideLoading()
					httpRequest.toast("请输入身份证号")
					return
				}
				httpRequest.request('/api/user/smrz', 'GET', {
					// 传参
					name: this.real_name, //真实姓名
					idcard: this.id_card, //身份证号
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				}).catch(err => {
					uni.hideLoading()
					httpRequest.toast(err.msg);
				})
			},
			uploadImg() {
				let _this = this;
				uni.showActionSheet({
					itemList: ['相机', '相册'],
					success: function(res) {

						// 选择相机走0
						if (res.tapIndex == 0) {
							httpRequest.chooseImage(1, ['camera']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageService(res[i])
								}
							}).catch(err => {});
						}
						// 选择相册走1
						if (res.tapIndex == 1) {
							httpRequest.chooseImage(1, ['album']).then(res => {
								for (var i = 0; i < res.length; i++) {

									_this.uploadImageService(res[i])
								}
							}).catch(err => {});
						}
					},
					fail: function(res) {}
				});
			},
			// 详情转载
			uploadImageService(url) {
				let _this = this;
				httpRequest.uploadFile('/api/Common/upload', url).then(res => {
					let image_item = res.fullurl;
					this.upImg = image_item
				}).catch(err => {});
			},
			uploadImgtext() {
				let _this = this;
				uni.showActionSheet({
					itemList: ['相机', '相册'],
					success: function(res) {

						// 选择相机走0
						if (res.tapIndex == 0) {
							httpRequest.chooseImage(1, ['camera']).then(res => {
								for (var i = 0; i < res.length; i++) {
									_this.uploadImageServicetext(res[i])
								}
							}).catch(err => {});
						}
						// 选择相册走1
						if (res.tapIndex == 1) {
							httpRequest.chooseImage(1, ['album']).then(res => {
								for (var i = 0; i < res.length; i++) {

									_this.uploadImageServicetext(res[i])
								}
							}).catch(err => {});
						}
					},
					fail: function(res) {}
				});
			},
			// 详情转载
			uploadImageServicetext(url) {
				let _this = this;
				httpRequest.uploadFile('/api/Common/upload', url).then(res => {
					let image_item = res.fullurl;
					this.upImgtext = image_item

				}).catch(err => {});
			},
			// 跳转审核状态页面
			/* 	tzshz() {
					uni.navigateTo({
						url: '/pages/mypage/shenheshangjrz'
					})
				}, */
			confirmSex(e) { //选择性别
				this.sex = e.value[0]
				this.show = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scsfz {
		width: 48%;
		height: 291rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.inputs {
		width: 60%;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}
</style>